<!DOCTYPE html>
<html lang="en">
<head>
    {include file="public/meta" /}
    {include file="public/link" /}
</head>
<body data-type="index" class="theme-white">
<div class="am-g tpl-g">
    {include file="public/header" /}
    {include file="public/left" /}
    {include file="public/content_top" /}
    <ol class="am-breadcrumb">
        <li><a href="../home/index.html" class="am-icon-home">首页</a></li>
        <li><a href="#">参数管理</a></li>
        <li class="am-active">合约管理</li>
        <li><a href="../transaction/contract_edit.html">添加合约</a></li>
    </ol>

    <div class="am-form-inline" role="form">
            <a href="{:url('contract')}?excel=1" class="am-btn am-btn-warning am-btn-sm">导出Excel表格</a>
    </div>

    <div class="widget am-cf">
        
        <hr data-am-widget="divider" class="am-divider am-divider-default"/>
        <div class="widget-body widget-body-lg am-fr">
            <div class="am-scrollable-horizontal">
                <table class="{$table}">
                    <thead>
                    <tr>
                        <th>品种名称</th>
                        <th>交易所代码</th>
                        <th>合约名称</th>
                        <th>合约代码</th>
                        <th>合约短码</th>
                        <th>合约类型</th>
                        <th>最近修改日期</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="list" id="vo" empty="$empty"}
                    <tr>
                        <td>{$vo['variety']['name'].'('.$vo['variety']['bourse_name'].')'}</td>
                        <td>{$vo.bourse_code}</td>
                        <td>{$vo.name}</td>
                        <td>{$vo.code}</td>
                        <td>{$vo.short}</td>
                        <td>{$vo.type}</td>
                        <td>{$vo['time']}</td>
                        <td>
                            <a href="#" onclick="del_contract({$vo.id})" class="am-btn am-btn-success am-btn-xs">删除合约</a>
                            <a href="contract_edit?id={$vo.id}&a={$a}&b={$b}" class="am-btn am-btn-success am-btn-xs">合约修改</a>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                <div class="dataTables_info" id="DataTables_Table_1_info">
                <div class="am-pagination-left">{$page}</div>
            </div>
        </div>
    </div>
    {include file="public/content_foot" /}
</div>
<form action="{:url('Transaction/contract')}" class="am-form-inline" role="form" id="form" method="get">
    <input type="hidden" name="name"/>
    <input type="hidden" name="start_query">
    <input type="hidden" name="end_query">
    <input type="hidden" name="status">
    <input type="hidden" name="page">
</form>
{include file="public/foot" /}
<script type="text/javascript">
    $(function () {
        var nav = $('.left-sidebar li.sidebar-nav-link');
        nav.removeClass("active");
//        nav.eq(1).find('a').addClass("active");
        nav.eq({$a}).find('ul').show();
        nav.eq({$a}).find('ul li').eq({$b}).find('a').addClass('active');
    });
    function sub(id) {
        $.ajax({
            url: "{:url('Users/edit')}",
            type: "post",
            data: {id: id},
            success: function (r) {
                if (r['code'] == 1) {
                    layer.msg(r['msg']);
                    setTimeout(function (){
                        window.location.reload();
                    },1500);
                } else {
                    layer.msg(r['msg']);
                }
            }
        });
    }

    function del_contract(id){
        $.ajax({
            url: "{:url('Transaction/del_contract')}",
            type: "post",
            data: {id: id},
            success: function (r) {
                if (r['code'] == 1) {
                    layer.msg(r['msg']);
                    setTimeout(function (){
                        window.location.reload();
                    },1500);
                } else {
                    layer.msg(r['msg']);
                }
            }
        });
    }
    function mold(id) {
        $.ajax({
            url: "{:url('Users/mold')}",
            type: "post",
            data: {id: id},
            success: function (r) {
                if (r == 1) {
                    alert_open('操作成功');
                } else {
                    alert_msg('操作失败');
                }
            }
        });
    }

    function Derive_excel(){
        $.ajax({
            url: "{:url('Users/index')}",
            type: "post",
            data: {excel: 1},
            success: function (r) {
                
            }
        });
    }
</script>
</body>
</html>
